/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.persistence.annotations.CascadeOnDelete;

/**
 *
 * @author dchapman
 */
@Entity
@Table(name = "ATCust")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ATCust.findAll", query = "SELECT a FROM ATCust a"),
    @NamedQuery(name = "ATCust.findByATCustID", query = "SELECT a FROM ATCust a WHERE a.aTCustID = :aTCustID")})
public class ATCust implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ATCustID")
    private Integer aTCustID;
    @JoinColumn(name = "CustID", referencedColumnName = "CId")
    @ManyToOne(optional = false)
    private Customer atCustomer;
    @OneToMany(cascade=CascadeType.ALL, orphanRemoval = true)
    @CascadeOnDelete
    @JoinTable(
        name="JTATCustToBeer",
        joinColumns={ @JoinColumn(name="ATCustID", referencedColumnName="ATCustID")},
        inverseJoinColumns={ @JoinColumn(name="ATBeerID", referencedColumnName="ATBeerID", unique=true)}
    )
    private List<ATBeer> atBeerCollection;

    public ATCust() {
    }

    public ATCust(Integer aTCustID) {
        this.aTCustID = aTCustID;
    }

    public Integer getATCustID() {
        return aTCustID;
    }

    public void setATCustID(Integer aTCustID) {
        this.aTCustID = aTCustID;
    }

    public Customer getAtCustomer() {
        return atCustomer;
    }

    public void setAtCustomer(Customer atCustomer) {
        this.atCustomer = atCustomer;
    }

    public List<ATBeer> getAtBeerCollection() {
        return atBeerCollection;
    }

    public void setAtBeerCollection(List<ATBeer> atBeerCollection) {
        this.atBeerCollection = atBeerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (aTCustID != null ? aTCustID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ATCust)) {
            return false;
        }
        ATCust other = (ATCust) object;
        if ((this.aTCustID == null && other.aTCustID != null) || (this.aTCustID != null && !this.aTCustID.equals(other.aTCustID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.ATCust[ aTCustID=" + aTCustID + " ]";
    }
    
}
